//采用正则表达式获得URL传参
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}

//下面用于图片上传预览
function setImagePreview(avalue, id, showid) {
	var docObj = document.getElementById(id);

	var imgObjPreview = document.getElementById(showid);
	if (docObj.files && docObj.files[0]) {
		
		 var file = docObj.files[0];
	        //这里我们判断下类型不是图片就返回
	        if(!/image\/\w+/.test(file.type)){ 
	                alert("请确保文件为图片类型");
	                return false;
	        }
			if(docObj.files[0].size>1048576){
			alert("图片尺寸最大1M");
			return;
			}
			// 火狐下直接设置img属性
			imgObjPreview.style.display = 'block';
			imgObjPreview.style.width = '150px';
			imgObjPreview.style.height = '180px';
			
			//对图片进行base64加密，返回的this.result就是结果
	        var reader = new FileReader();
	        reader.readAsDataURL(file);
	        reader.onload = function(e){
//	                result.innerHTML = '<img src="'+this.result+'" alt=""/>';
	                document.getElementById(showid+"Code").value=this.result;
	        }
		// imgObjPreview.src = docObj.files[0].getAsDataURL();
		// 火狐7以上版本不能用getAsDataURL()方法，用以下方法即可
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		// IE�£�ʹ���˾�
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		// IE下使用滤镜
		localImagId.style.width = "120px";
		localImagId.style.height = "180px";
		// 图片异常捕获
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters
					.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch (e) {
			alert("您上传的图片格式不正确，请重新选择！");
			return false;
		}
		imgObjPreview.style.display = 'none';
		document.selection.empty();
	}
	return true;
}

//根据资金流水type返回中文
function returnlsType(code){
	if(code==0){
		return "全部";
	}else if(code==1){
		return "充值";
	}else if(code==2){
		return "提现";
	}else if(code==3){
		return "冻结";
	}else if(code==4){
		return "解冻";
	}else if(code==5){
		return "扣款";
	}else if(code==6){
		return "返奖至资金帐户";
	}else if(code==7){
		return "返奖至借记卡";
	}
}

//时间戳转换时间格式
function add0(m){return m<10?'0'+m:m }
function getLocalTime(time,formateType){
	//formateType == 'yyyy-MM-dd' 年月日
	//formateType == 'yyyy-MM-dd HH:mm:ss' 年月日 时分秒
	//time是整数，否则要parseInt转换
	var time = new Date(time);
	var y = time.getFullYear();
	var m = time.getMonth()+1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	if(formateType == 'yyyy-MM-dd HH:mm:ss'){
		return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
	}else if(formateType == 'yyyy-MM-dd'){
		return y+'-'+add0(m)+'-'+add0(d);
	}
}

//关闭弹出框
function closeWarnInfoDiv(id){
	$('#'+id).hide();
}

//隐藏姓名中的名字
function hideName(fullname){
	var hyphenated = ['欧阳','太史','端木','上官','司马','东方','独孤','南宫','万俟','闻人','夏侯','诸葛','尉迟','公羊','赫连','澹台','皇甫',    
	                  '宗政','濮阳','公冶','太叔','申屠','公孙','慕容','仲孙','钟离','长孙','宇文','城池','司徒','鲜于','司空','汝嫣','闾丘','子车','亓官',    
	                  '司寇','巫马','公西','颛孙','壤驷','公良','漆雕','乐正','宰父','谷梁','拓跋','夹谷','轩辕','令狐','段干','百里','呼延','东郭','南门',    
	                  '羊舌','微生','公户','公玉','公仪','梁丘','公仲','公上','公门','公山','公坚','左丘','公伯','西门','公祖','第五','公乘','贯丘','公皙',    
	                  '南荣','东里','东宫','仲长','子书','子桑','即墨','达奚','褚师'];    
	                  var vLength = fullname.length;    
	                  var lastname = '', firstname = '';//前为姓,后为名    
	                  if(vLength > 2){    
	                      var preTwoWords = fullname.substr(0, 2);//取命名的前两个字,看是否在复姓库中    
	                      if($.inArray(preTwoWords, hyphenated) > -1){    
	                          lastname = preTwoWords;    
	                          firstname = fullname.substr(2);    
	                      }else{    
	                          lastname = fullname.substr(0, 1);    
	                          firstname = fullname.substr(1);    
	                      }    
	                  }else if(vLength == 2){//全名只有两个字时,以前一个为姓,后一下为名    
	                      lastname = fullname.substr(0, 1);    
	                      firstname = fullname.substr(1);    
	                  }else{    
	                      lastname = fullname;    
	                  } 
	                
	                  var showName=lastname;
	                  for(var i=0;i<firstname.length;i++){
	                	  showName+="*";
	                  }
	                  return showName; 
}